
import numpy as np

a = np.arange(25).reshape(5, 5)
b = np.ones(shape=(5, 5)) * 2
# print(a)
# print(b)
# [[ 0  1  2  3  4]
#  [ 5  6  7  8  9]
#  [10 11 12 13 14]
#  [15 16 17 18 19]
#  [20 21 22 23 24]]
# [[2. 2. 2. 2. 2.]
#  [2. 2. 2. 2. 2.]
#  [2. 2. 2. 2. 2.]
#  [2. 2. 2. 2. 2.]
#  [2. 2. 2. 2. 2.]]


# print(a+b)
# print(a-b)
# print(a*b)
# print(a/b)
# print(a**2)

# [[ 2.  3.  4.  5.  6.]
#  [ 7.  8.  9. 10. 11.]
#  [12. 13. 14. 15. 16.]
#  [17. 18. 19. 20. 21.]
#  [22. 23. 24. 25. 26.]]
# [[-2. -1.  0.  1.  2.]
#  [ 3.  4.  5.  6.  7.]
#  [ 8.  9. 10. 11. 12.]
#  [13. 14. 15. 16. 17.]
#  [18. 19. 20. 21. 22.]]
# [[ 0.  2.  4.  6.  8.]
#  [10. 12. 14. 16. 18.]
#  [20. 22. 24. 26. 28.]
#  [30. 32. 34. 36. 38.]
#  [40. 42. 44. 46. 48.]]
# [[ 0.   0.5  1.   1.5  2. ]
#  [ 2.5  3.   3.5  4.   4.5]
#  [ 5.   5.5  6.   6.5  7. ]
#  [ 7.5  8.   8.5  9.   9.5]
#  [10.  10.5 11.  11.5 12. ]]
# [[  0   1   4   9  16]
#  [ 25  36  49  64  81]
#  [100 121 144 169 196]
#  [225 256 289 324 361]
#  [400 441 484 529 576]]
#


def calculate(num1, num2) -> np.integer:
    """
        :param num1:  the first calculation parameter
        :param num1:  the second calculation parameter
        :return: Return calculation result without any intermediate variables
        """
    # -- write your code here --
    # np.add(num1, num2, out=num2)  # [1 1 1]
    np.subtract(num1, num2)  # [1 1 1]
    np.subtract(num1, num2, out=num1)  # [0 0 0]
    # np.divide(num1, 2, out=num1)  # todo
    # np.negative(num1, out=num1)  # [-1 -1 -1]
    # np.multiply(num1, num2, out=num1)  # [1 1 1]
    return num1


num1 = np.array([1, 1, 1])
num2 = np.array([1, 1, 1])
# print(calculate(num1, num2))
# print(type(num1))
# print(type([1, 1, 1]))
# <class 'numpy.ndarray'>
# <class 'list'>

# 02

arr = np.arange(12).reshape(3, 4)
# print(np.sum(arr))
# 66

arr = np.arange(2, 10)
print(arr)
print(np.sum(arr))
print(np.prod(arr))
print(np.cumsum(arr))
print(np.cumprod(arr))

# [2 3 4 5 6 7 8 9]
# 44
# 362880
# [ 2  5  9 14 20 27 35 44]
# [     2      6     24    120    720   5040  40320 362880]
#


